/*
 * @Author: 徐建辰
 * @LastEditors: 徐建辰
 * @Description: 统一封装api请求
 */
const {baseUrl} = require('../tools/constant')

module.exports = function request(options) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: `${baseUrl}/${options.url}`,
      method: options.method || 'GET',
      header: options.header,
      data: options.data || {},
      success(res) {
        resolve(res)
      },
      fail(err) {
        reject(err)
      }
    })
  })
}